import axios from 'axios';
import { reqWithJSON,reqNoParams } from './axiosFun';

export const goodsList = (params) => {
  if(params.platTypeStr){
     params.platType =parseInt(params.platTypeStr);
  }
  return reqWithJSON("post", "/api/m/bms/shopg/page",params)
};

export const jysPrice= (params) => {
  return reqWithJSON("patch", "/api/m/bms/shopg/offer",params)
};


export const changeStatus= (params) => {
  return reqNoParams("patch", "/api/m/bms/shopg/offer/state/"+params.id+"/"+params.effFlg)
};

export const batchChangeStatus= (params) => {
  return reqWithJSON("patch", "/api/m/bms/shopg/offer/bstate/"+params.effFlg,params)
};

export const offerHisList= (params) => {
  return reqNoParams("get", "/api/m/bms/shopg/offer/his/"+params.id)
};

export const changeMode= (params) => {
  return reqNoParams("patch", "/api/m/bms/shopg/offer/mode/"+params.id+"/"+params.offerMode)
};

export const changeTargetPrice= (params) => {
  return reqNoParams("patch", "/api/m/bms/shopg/offer/price/"+params.id+"/"+params.minSalePrice)
};
export const refreshGoods= (params) => {
  return reqNoParams("get", "/api/m/bms/shop/refreshGoods")
};
export const refreshPrice= (params) => {
  return reqNoParams("get", "/api/m/bms/shopg/goods/refresh/"+params.id)
};


/**
 * 以下为目标价管理
 */
export const settPrice= (params) => {
  if(params.type && params.type=='upd'){
    return reqNoParams("POST", "/api/m/bms/offerp/upd/"+params.id+"/"+params.minSalePrice)
  }else{
    return reqWithJSON("POST", "/api/m/bms/offerp/add",params)
  }
};

export const disablePrice= (params) => {
  return reqNoParams("DELETE", "/api/m/bms/offerp/disable/"+params.id)
};

export const reusePrice= (params) => {
  return reqNoParams("PATCH", "/api/m/bms/offerp/reuse/"+params.id)
};

export const deletePrice= (params) => {
  return reqNoParams("DELETE", "/api/m/bms/offerp/del/"+params.id)
};

export const queryPrice= (params) => {
  return reqWithJSON("Post", "/api/m/bms/offerp/page/"+params.pageNo+"/"+params.pageSize,params)
};
